<!DOCTYPE html>
<%@ page language="java" import="com.compuvest.web.*,java.util.*,java.text.*" pageEncoding="UTF-8" %>

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<fmt:setBundle basename="properties.Compuvest" var="cv" scope="page" />

<jsp:useBean id="sb" class="SQLBean" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    Customer cust = basket.getCustomer();
    if(cust == null) {
	response.sendRedirect(/*application.getInitParameter("https") +*/ "./CustomerForm.jsp");
	return;
    }
    DecimalFormat prf = new DecimalFormat("$###,##0.00");

    ArrayList<Order> orders = sb.getOrders(cust.getCustomerID());
%>
<html>
<head>
<title><fmt:message key='webcorp' bundle='${cv}'/> Orders History</title>
<%@include file="./incl/scripts.txt" %>
</head>
<body>

<div id='cvbody'>

 <head:show />

 <div id='cvcont'>
  <table id='cvmain'>
  <colgroup><col width='80px'/><col width='*'/><col width='80px'/></colgroup>
  <tbody>
   <tr>
    <td id='cvleft' valign="top">


    </td>
    <td id='cvcenter' align="center" valign="top">

<div class='bighead'>Orders History</div>
<br/>

<table style='width:80%;background:silver;font:bold 8.3pt Arial;height:18px;'>
 <tr height='26'><td colspan=10 background="../img/tbg.png">&nbsp;</td></tr>
 <tr bgcolor='lightblue'><th></th><th>Order #</th><th>Date</th><th>COD</th><th>Shipping</th><th>Delivery</th><th>WA Tax</th><th>Total</th><th>Tracking #</th></tr>
<%
    boolean bground = false;
    for(Order order : orders) {
%>
 <tr bgcolor='#ffff<%= (bground = !bground) ? "cf" : "ef" %>' align='center'>
  <td>
<%
	if(order.haveHistory()) {
%>
  <a href='<%= "./" /*application.getInitParameter("https")*/ %>OrderPrint.jsp?oid=<%= order.getOrderID() %>'>Print</a>
<%
	}
%>
  </td>
  <td><%= order.getOrderNo() %></td>
  <td><%= order.getOrderDate() %></td>
  <td><%= "Y".equals(order.getCOD()) ? "COD" : "" %></td>
  <td><%= order.getShippingCost() == 0d ? "" : prf.format(order.getShippingCost()) %></td>
  <td><%= order.getShippingDesc() %></td>
  <td><%= order.getTaxCost() == 0d ? "" : prf.format(order.getTaxCost()) %></td>
  <td><%= prf.format(order.getGrandTotal()) %></td>
  <td>
<%
	ArrayList<Tracking> tracks = order.getTracking();
	if(tracks.size() != 0) {
	    for(Tracking track : tracks) {
%>
  <%= track.getShippingCompany().length() == 0 ? "" : track.getShippingCompany() + ": " %><%= track.getStatusShort() %><br/>
<%
	    }
	}
	else {
%>
 Processing...
<%
	}
%>
  </td>
 </tr>
<%
    }
%>
</table>

    </td>
    <td id='cvright' valign="top">

    </td>
   </tr>
  </tbody>
  </table>
 </div>

 <div id='cvfoot'></div>
</div>

</body>
</html>
